Lens distortion is one of the most important factors that affect quality of a digital image generated by an image sensor, and a distorted image needs to be corrected.
Among existing methods for correcting lens distortion of the digital image, the following two methods are most commonly used to correct the digital image at a time.
One method is to implement one-off lens distortion correction by using an online row buffer. In this method, lens distortion correction is performed in horizontal and vertical directions at the same time when image data is acquired from a lens. The one-off correction requires a large number of row buffers to store coordinate data of distorted lines (distorted lines). This type of row buffer is a small temporary storage unit that is configured to store a row or a part of a row of the image data. Before a new coordinate of a corrected image is generated, a large number of row buffers are required to store data of adjacent rows. How many row buffers are required depends on what a maximum distortion degree is. For example, the maximum distortion degree is 20%, then for an image whose resolution is 720*1280, 20%*720/2=72 row buffers are required. The row buffer is generally a system-on-chip memory. So many row buffers may lead to a high cost, which is hard to accept in product implementation.
The other method is to implement the one-off lens distortion correction by using an offline DDR (DDR SDRAM, Double Data Rate Synchronous Dynamic Random Access Memory, hereinafter referred to as “DDR”). In this method, lens distortion correction is performed in direction and vertical directions at the same time after image data is acquired from a lens and stored in an off-chip DDR. The DDR receives a data block formed by one frame or two frames of data, and implements correction by changing a position of a pixel in an image. DDR write addresses of pixels of a corrected image are consecutive. To ensure that the DDR write addresses of the pixel of the corrected image is consecutive, a DDR read address of a pixel of an original image before correction should not satisfy consecutiveness, which causes that a DDR of a corresponding pixel cannot be consecutively read according to the read addresses, but can only be read in a skipping manner according to nonconsecutive addresses. However, a refresh cycle is required during a DDR read operation. That the DDR cannot be consecutively read leads to a low DDR read efficiency, which is hard to accept in product implementation.
Although the DDR read addresses of the corresponding pixel are inconsecutive, other useless pixel data that includes the corresponding pixel may be consecutively read to ensure that the read addresses are consecutive. A size of a block that is read at a time is equal to “consecutive length*consecutive number”. The consecutive length refers to the sum of pixels that can be read consecutively in a refresh cycle; and if a distortion occurs, the consecutive reading stops. The consecutive length may be a transverse length in a horizontal direction. The consecutive number refers to the number of times, allowed by a system, of restarting the consecutive reading in a block read by the DDR at a time. The consecutive length may be a column length in a vertical direction. The consecutive length and the consecutive number herein are both determined by a radial distortion degree, but the “consecutive length*consecutive number” is limited by product implementation performance. When the radial distortion degree is relatively high, “consecutive length*consecutive number” determined by the radial distortion degree may exceed a product implementation performance limit, and therefore it cannot be ensured that the read addresses are consecutive.
The foregoing correction methods have a high cost and a low efficiency. Therefore, a method and an apparatus for correcting lens distortion that have a low cost and a high correction efficiency are required.